﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WebApplication2.Instrument;
using BLL;
using Model;
namespace WebApplication2
{
    public partial class WebForm2 : System.Web.UI.Page
    {

        protected void Page_Load(object sender, EventArgs e)
        {

            UnobtrusiveValidationMode = UnobtrusiveValidationMode.None;
            if (!IsPostBack)
            { 
                TextBox3.Text = "";
                TextBox4.Text = "";
            }
        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            if (TextBox8.Text == Session["emailCode"].ToString())
            {

                UserinforModel p = new UserinforModel();
                p.UName = TextBox1.Text;
                p.UserName = TextBox2.Text;
                p.UserPwd = TextBox4.Text;
                p.UserAge = Convert.ToInt32(TextBox5.Text);
                p.UsersSex = TextBox6.Text;
                p.UsersPostbox = TextBox7.Text;
                if (UserinforManger.AddProduct(p))
                {

                    Response.Redirect("");
                }
                else
                {
                    Response.Write(" <script>alert('失败')</script>");
                }


            }
            else
            {

                Button3.Text = "获取验证码";
                Label9.Text = "验证码错误！";
            }
        }



        protected void Button3_Click(object sender, EventArgs e)
        {


                if (TextBox7.Text != "")
                {
                    if (TextBox7.Text.Contains("@qq.com"))
                    {
                        PostAndCode.SendPost(TextBox7.Text.Trim());
                      
                        Button3.Text = "已发送验证码";
                        Label8.Text = " ";
                        Label1.Text = Session["emailCode"].ToString();
                    }
                    else
                    {
                        Label8.Text = "邮箱格式错误！";
                    }


                }
                else
                {
                    Label8.Text = "邮箱不能为空";
                }
        }

        protected void TextBox3_TextChanged(object sender, EventArgs e)
        {
            this.TextBox3.Attributes["value"] = Request.Form[TextBox3.ClientID];
        }

        protected void TextBox4_TextChanged(object sender, EventArgs e)
        {
            this.TextBox4.Attributes["value"] = Request.Form[TextBox4.ClientID];
        }
    }
}